<!--  -->bleColumns1
<template>
    <div class="cssToolbar">
        <Toolbar :items="['查询', '打印布飞', '织布通知单', '打印机台纸', '导出', '开需求单', '反审']" @select="cx" @flycloth="dyBf"
            @picking="pickings" @paper="paper" @counter="counters" @export="exports" @zbtzd="zbtzds">
        </Toolbar>
    </div>
    <div class="cssTable">
        <a-table size="mini" :scrollbar="true" sticky-header stripe :bordered="true" :columns="tableColumns"
            :row-selection="{ showCheckedAll: true, width: 50 }" :style="{
                height: pageData.rHeight - 250 + 'px'
            }" v-model:selected-keys="selectedRowKeys" :loading="table.tableLoading" :data="table.dataList"
            :pagination="false" :rowKey="rowKey">
            <template #planOrderState="{ record }">
                <a-button v-if="record.planOrderState == 2" type="primary" size="mini" status="danger" shape="round">
                    紧急&nbsp
                </a-button>
                <a-button v-if="record.planOrderState == 1" type="primary" size="mini" status="success" shape="round">
                    &nbsp&nbsp急&nbsp&nbsp
                </a-button>
                <a-button v-if="record.planOrderState == 0" status="danger" size="mini" shape="round">
                    正常&nbsp
                </a-button>
            </template>
            <template #planState="{ record }">
                <span v-if="record.planState == 0">自行生产</span>
            </template>
        </a-table>
    </div>
    <a-modal v-model:visible="visible" ok-text="打印" @ok="print" :width="800">
        <template #title>
            机台织造生产通知单
        </template>
        <div id="jtdy2">
            <table class="isTable">
                <tr>
                    <td>机号</td>
                    <td>{{isDatasShuju.planMachineCode}}</td>
                    <td>位置号</td>
                    <td>{{isDatasShuju.planMachineCode}}</td>
                    <td>织造序号</td>
                    <td>{{isDatasShuju.weaveCode}}</td>
                </tr>
                <tr>
                    <td>订单号</td>
                    <td>{{isDatasShuju.customOrderNo}}</td>
                    <td>预排匹数</td>
                    <td>{{isDatasShuju.pieceNum}}</td>
                    <td>颜色</td>
                    <td>{{isDatasShuju.colorName}}</td>
                </tr>
                <tr>
                    <td>针筒</td>
                    <td colspan="3">{{isDatasShuju.workDrum}}</td>
                    <td>抽针</td>
                    <td>{{ isDatasShuju.drawnNeedleState == 0 ? '抽针' : '圆筒' }}</td>
                </tr>
                <tr>
                    <td>坯布编号</td>
                    <td colspan="3">{{isDatasShuju.greyCode}}</td>
                    <td>批号</td>
                    <td>{{isDatasShuju.greyBatchNo}}</td>
                </tr>
                <tr>
                    <td>坯布名称</td>
                    <td colspan="3">{{isDatasShuju.greyName}}</td>
                    <td></td>
                    <td>巨丰</td>
                </tr>
            </table>
            <table class="isTable1">
                <!-- <tr class="isTrTdNo">
                <td>666</td>
                <td>666</td>
                <td>666</td>
                <td>666</td>
                <td>666</td>
                <td>666</td>
                <td>666</td>
                <td>666</td>
            </tr> -->
                <tr>
                    <td colspan="2">原料编号</td>
                    <td colspan="2">原料名称</td>
                    <td colspan="1">纱牌</td>
                    <td colspan="2">色号/色称/等级</td>
                    <td colspan="1">纱批</td>
                </tr>
                <tr v-for="item in isDatasShuju.planOrderRawmaterials">
                    <td colspan="2">{{item.rawmaterialCode}}</td>
                    <td colspan="2">{{item.rawmaterialName}}</td>
                    <td colspan="1">{{item.yarnCard}}</td>
                    <td colspan="2">{{item.colorCode}}/{{item.colorName}}/{{item.level}}</td>
                    <td colspan="1">{{item.batch}}</td>
                </tr>
            </table>
            <div class="footer">
                <div>
                    <span>纱长:</span><span>{{isDatasShuju.yarnLong}}</span>
                    <!-- <span>面:&nbsp;&nbsp;</span><span>J32S紧密棉条:&nbsp;&nbsp;</span><span>19.3CM/50针</span> -->
                </div>
                <!-- <div>
                    <span>中:&nbsp;&nbsp;</span><span>100D低弹:&nbsp;&nbsp;</span><span>14.3CM/50针</span>
                </div>
                <div>
                    <span>耳仔:&nbsp;&nbsp;</span><span>10S棉:&nbsp;&nbsp;</span><span>9CM/50针</span>
                </div> -->
            </div>
        </div>
    </a-modal>
    <a-modal v-model:visible="visibles1" ok-text="打印" @ok="prints" :width="800">
        <template #title>
            织布通知单
        </template>
        <div class="isZbous" id="zbdy2">
            <div class="isZbouss">试纱单:{{isDatasShuju.businessType}}</div>
            <div class="isZbouss1">
                <span><span>客户名称:{{isDatasShuju.customName}}</span><span></span></span><span><span>客户生产单号:{{isDatasShuju.customOrderNo}}</span><span></span></span>
            </div>
            <div class="isZbouss2">
                <span>
                    <span>织厂:{{isDatasShuju.businessDepartment}}</span><span></span>
                </span>
                <span>
                    <span>开单日期:{{isDatasShuju.planDate}}</span><span></span>
                </span>
                <span>
                    <span>完成日期:{{isDatasShuju.shipmentDate}}</span><span></span>
                </span>
                <span>
                    <span>织工:{{isDatasShuju.price}}</span><span></span>
                </span>
            </div>
            <table class="isTable">
                <tr>
                    <td colspan="2">营销部门</td>
                    <td colspan="4"></td>
                    <td colspan="2">计划单号</td>
                    <td colspan="4">{{isDatasShuju.planOrderCode}}</td>
                    <td colspan="2">织造序号</td>
                    <td colspan="4">{{isDatasShuju.weaveCode}}</td>
                </tr>
                <tr>
                    <td colspan="2">编号</td>
                    <td colspan="4">{{isDatasShuju.greyCode}}</td>
                    <td colspan="2">品名</td>
                    <td colspan="4">{{isDatasShuju.greyName}}</td>
                    <td colspan="2">颜色</td>
                    <td colspan="4">{{isDatasShuju.colorName}}</td>
                </tr>
                <tr>
                    <td colspan="2">机型</td>
                    <td colspan="4">{{isDatasShuju.grey[0].mercery}}</td>
                    <td colspan="2">针寸数</td>
                    <td colspan="4">{{isDatasShuju.workDrum}}</td>
                    <td colspan="2">抽针/圆筒</td>
                    <td colspan="4">{{ isDatasShuju.drawnNeedleState == 0 ? '抽针' : '圆筒' }}</td>
                </tr>
                <tr>
                    <td colspan="2">批号</td>
                    <td colspan="4">{{isDatasShuju.greyBatchNo}}</td>
                    <td colspan="2">数量</td>
                    <td colspan="4">{{isDatasShuju.orderWeight}}</td>
                    <td colspan="2">打卷类型</td>
                    <td colspan="4">{{isDatasShuju.type}}</td>
                </tr>
                <tr>
                    <td colspan="2">成品布号</td>
                    <td colspan="4">{{isDatasShuju.productColthCode}}</td>
                    <td colspan="2">织损</td>
                    <td colspan="4">{{isDatasShuju.lossRate}}</td>
                    <td colspan="2">匹数</td>
                    <td colspan="4">{{isDatasShuju.pieceNum}}</td>
                </tr>
                <tr>
                    <td colspan="2">成品门幅</td>
                    <td colspan="4">{{isDatasShuju.width}}</td>
                    <td colspan="2">成品克重</td>
                    <td colspan="4">{{isDatasShuju.weight}}</td>
                    <td colspan="2">洗后克重</td>
                    <td colspan="4">{{isDatasShuju.washWeight}}</td>
                </tr>
                <tr>
                    <td colspan="2">材料名称</td>
                    <td colspan="2">品牌</td>
                    <td colspan="2">批次</td>
                    <td colspan="2">色号/色称</td>
                    <td colspan="2">比例</td>
                    <td colspan="2">织造</td>
                    <td colspan="2">可发纱量</td>
                    <td colspan="2">注释</td>
                </tr>
                <tr v-for="item in isDatasShuju.planOrderRawmaterials">
                    <td colspan="2">{{item.rawmaterialName}}</td>
                    <td colspan="2">{{item.yarnCard}}</td>
                    <td colspan="2">{{item.batch}}</td>
                    <td colspan="2">{{item.colorCode+'/'+item.colorName}}</td>
                    <td colspan="2">{{item.yarnProportion}}</td>
                    <td colspan="2">{{item.weaveLoss}}</td>
                    <td colspan="2">{{item.canDeliveryYarnNum}}</td>
                    <td colspan="2"></td>
                </tr>
            </table>
            <div class="gyYaoqiu">工艺要求</div>
            <div class="gyYaoqius">
                <div style="width:100%;overflow:auto">
                <div style="white-space:nowrap">
                    <span >上排</span>
                    <input disabled v-for="(item, index) in zzpzdata" :key="index"
                        style="width: 30px;border: 1px solid black; padding: 5px;text-align: center;"
                        v-model="item.upBasin" />
                </div>
                <div style="white-space:nowrap">
                    <span>下排</span>
                    <input disabled v-for="(item, index) in zzpzdata" :key="index"
                        style="width: 30px;border: 1px solid black; padding: 5px;text-align: center;"
                        v-model="item.belowBasin" />

                </div>
            </div>
            <div v-for="(item, index) in sjdata.sj as any"
                style="text-align: center;margin: 20px auto;width: 100%;overflow-x: auto;">
                <div
                    style="text-align: center;color: #165DFF;font-size: 16px;background-color: aliceblue;border-bottom:0.5px solid #ccc ;">
                    {{ item.type }}
                </div>

                <div class="thead" style="background-color: aliceblue;">
                    <div class="th" style="width: 50px;">序号</div>
                    <div class="th" style="width:150px">用针</div>
                    <div class="th" style="width:40px" v-for="i2 in item.typeData[0].needleList" :key="i2.way">
                        {{ i2.way }}
                    </div>
                </div>
                <div class="tbody" v-for="i1 in item.typeData">
                    <div class="td" style="width: 50px;">{{ i1.serialNumber }}</div>
                    <div class="td" style="width: 150px;">
                        <a-input disabled v-model="i1.needleName"></a-input>
                    </div>
                    <div class="td" style="  width: 40px; vertical-align: middle; border: 1px solid gray;"
                        v-for="i2 in i1.needleList">
                        <div style="width: 100%;height: 100%;">{{ tags.filter(o => o.id
                                === i2.needle)[0]?.val
                        }}
                        </div>
                    </div>
                </div>
            </div>
            <div class="tbody" style="margin-top: 10px;">
                <div
                    style="text-align: center;color: #165DFF;font-size: 16px;background-color: aliceblue;border-bottom:0.5px solid #ccc ;">
                    排纱
                </div>
                <div class="trow" v-for="(item, index) in psList">
                    <div style="border: 1px solid #ccc;height: 30px;box-sizing: border-box;"
                        v-for="(item1, index1) in item">
                        <input disabled v-model="item1.val"
                            v-if="!((index > 0 && (index1 == 0 || index1 == 1)) || (index == 0 && index1 === 2))"
                            style="width: 80px;vertical-align: top;height: 100%;text-align: center;"
                            :class="{ 'active': (index1 == 0 || index1 == 1) }" />
                        <div v-if="((index > 0 && (index1 == 0 || index1 == 1)) || (index == 0 && index1 === 2))"
                            style="width: 80px;vertical-align: top;height: 100%;text-align: center;"
                            :class="{ 'active': (index1 == 0 || index1 == 1) }">{{ item1.val }}</div>
                    </div>
                </div>
            </div>
            <div style="display:flex;align-items:center;">
                <div style="width:50%">
                    <span>裁口排针</span>
                    <a-input disabled v-model="ckpzobj.pinHeader">

                    </a-input>
                </div>
                <div style="width:50%">
                    <span>纱线排列</span>
                    <a-input disabled v-model="ckpzobj.arrangement">

                    </a-input>
                </div>
            </div>
            </div>
            <table class="isTable">
                <tr>
                    <td>实际参数</td>
                    <td>齿轮</td>
                    <td>布架宽度</td>
                    <td>底座垫片</td>
                    <td :style="{width:'160px',textAlign:'left'}">机速:</td>
                    <td :style="{width:'160px',textAlign:'left'}">实开模板:</td>
                </tr>
                <tr>
                    <td></td>
                    <td>{{isDatasShuju.machineStandard.length != 0?isDatasShuju.machineStandard[0].gear:''}}</td>
                    <td>{{isDatasShuju.machineStandard.length !=0?isDatasShuju.machineStandard[0].clothRackWidth:''}}</td>
                    <td>{{isDatasShuju.machineStandard.length != 0?isDatasShuju.machineStandard[0].baseGasket:''}}</td>
                    <td :style="{width:'160px',textAlign:'left'}">布架活动胶:</td>
                    <td :style="{width:'160px',textAlign:'left'}">针盘高度:</td>
                </tr>
                <tr>
                    <td>布架张力A-D</td>
                    <td>布架张力1-16</td>
                    <td>送纱盘-面盘</td>
                    <td>送纱盘-中盘</td>
                    <td :style="{width:'160px',textAlign:'left'}">布架张力:</td>
                    <td :style="{width:'160px',textAlign:'left'}">布架幅宽:</td>
                </tr>
                <tr>
                    <td>{{isDatasShuju.machineStandard.length != 0?isDatasShuju.machineStandard[0].clothTensionAD:''}}</td>
                    <td>{{isDatasShuju.machineStandard.length != 0?isDatasShuju.machineStandard[0].clothTensionOS:''}}</td>
                    <td>{{isDatasShuju.machineStandard.length != 0?isDatasShuju.machineStandard[0].sandTableSurfacePlate:''}}</td>
                    <td>{{isDatasShuju.machineStandard.length != 0?isDatasShuju.machineStandard[0].sandTrayMiddlePlate:''}}</td>
                    <td :style="{width:'160px',textAlign:'left'}">下机克重:</td>
                    <td :style="{width:'160px',textAlign:'left'}">下机封度:</td>
                </tr>
                <tr>
                    <td>送纱盘-底盘</td>
                    <td>争食</td>
                    <td>分食</td>
                    <td>不争不分</td>
                    <td :style="{width:'160px',textAlign:'left'}">织针型号:</td>
                    <td rowspan="4">{{isDatasShuju.planMachineCode?isDatasShuju.planMachineCode:''}}</td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td>{{isDatasShuju.machineStandard.length == 0?'':isDatasShuju.machineStandard[0].dodge==1?'√':''}}</td>
                    <td>{{isDatasShuju.machineStandard.length == 0? '' : isDatasShuju.machineStandard[0].broken==1?'√':''}}</td>
                    <td>{{isDatasShuju.machineStandard.length == 0?'':isDatasShuju.machineStandard[0].allTrue==1?'√':''}}</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td>织针型号</td>
                    <td>织针1段</td>
                    <td>织针2段</td>
                    <td>织针3段</td>
                    <td>织针需求等级</td>
                </tr>
                <tr>
                    <td>{{isDatasShuju.machineStandard.length != 0?isDatasShuju.machineStandard[0].needleModel:''}}</td>
                    <td>{{isDatasShuju.machineStandard.length == 0 ?'':isDatasShuju.machineStandard[0].needleOnePerod==1?'√':''}} </td>
                    <td>{{isDatasShuju.machineStandard.length == 0 ?'':isDatasShuju.machineStandard[0].needleTwoPerod==1?'√':''}} </td>
                    <td>{{isDatasShuju.machineStandard.length == 0 ?'':isDatasShuju.machineStandard[0].needleThreePerod==1?'√':''}} </td>
                    <td>{{isDatasShuju.machineStandard.length != 0?isDatasShuju.machineStandard[0].needleGrade:''}}</td>
                </tr>
                <tr>
                    <td class="trTds">计划单备注</td>
                    <td colspan="5" >{{isDatasShuju.remark?isDatasShuju.remark:''}}</td>
                </tr>
                <tr>
                    <td class="trTds">工艺备注</td>
                    <td colspan="5">{{isDatasShuju.otherRemark?isDatasShuju.otherRemark:''}}</td>
                </tr>
            </table>
            <div class="footers">
                <div>
                    <span>制单:{{isDatasShuju.tabulationPerson?isDatasShuju.tabulationPerson:''}}</span>
                    <span>制单时间:{{isDatasShuju.planDate?isDatasShuju.planDate:''}}</span>
                    <span>审核:{{isDatasShuju.auditPerson?isDatasShuju.auditPerson:''}}</span>
                </div>
            </div>
        </div>
    </a-modal>
    <paginationCopys :total="total" show-total show-jumper show-page-size @change="PageSize" @page-size-change="change1"
        style="justify-content: center" />
    <a-drawer ok-text='保存' cancel-text='关闭' :drawer-style="{ 'zIndex': 999 }" :width="800"
        popup-container=".main-base-style" :height="pageData.rHeight" :visible="pageData.showAdd" placement="bottom"
        unmountOnClose @cancel="sideNo1" @ok="sideOks" :closable="false">
        <template #title>
            开需求单
        </template>
        <div>
            <div>
                <a-form ref="formRef" :model="dataForms" size="mini" layout="vertical">
                    <div>
                        <a-space>
                            <a-form-item label="计划需求单号" field="code">
                                <!-- 标记 -->
                                <a-input v-model="dataForms.pickCode" disabled :style="{ width: '280px' }" />
                            </a-form-item>
                            <a-form-item label="开单日期">
                                <a-input v-model="dataForms.pickDate" disabled :style="{ width: '280px' }" />
                            </a-form-item>
                            <a-form-item label="织造序号">
                                <a-input v-model="dataForms.weaveCode" disabled :style="{ width: '280px' }" />
                            </a-form-item>
                            <a-form-item label="计划单号">
                                <a-input v-model="dataForms.planOrderCode" disabled :style="{ width: '280px' }" />
                            </a-form-item>
                            <a-form-item label="坯布名称">
                                <a-input v-model="dataForms.greyName" disabled :style="{ width: '280px' }" />
                            </a-form-item>
                        </a-space>
                        <a-space>
                            <a-form-item label="客户名称">
                                <a-input v-model="dataForms.customName" disabled :style="{ width: '280px' }" />
                            </a-form-item>
                            <a-form-item label="坯布编号">
                                <a-input v-model="dataForms.greyCode" disabled :style="{ width: '280px' }" />
                            </a-form-item>
                            <a-form-item label="部门编号">
                                <a-input v-model="dataForms.departmentCode" :style="{ width: '280px' }" />
                            </a-form-item>
                            <a-form-item label="部门名称">
                                <a-input v-model="dataForms.departmentName" :style="{ width: '280px' }" />
                            </a-form-item>
                            <a-form-item label="楼层">
                                <a-select popup-container="html"  v-model="dataForms.departmentStorey" :style="{ width: '280px', }">
                                    <a-option>1</a-option>
                                    <a-option>2</a-option>
                                    <a-option>3</a-option>
                                    <a-option>4</a-option>
                                    <a-option>5</a-option>
                                    <a-option>6</a-option>
                                    <a-option>7</a-option>
                                </a-select>
                            </a-form-item>
                        </a-space>
                        <a-space>
                            <a-form-item label="备注">
                                <a-input v-model="dataForms.remark" :style="{ width: '840px' }" />
                            </a-form-item>
                        </a-space>
                    </div>
                </a-form>
                <a-table size="mini" :scrollbar="true" sticky-header stripe :columns="tableColumns1"
                    :loading="tables.tableLoading" :data="tables.dataList" :pagination="pagination"
                    :bordered="{ headerCell: true }">
                    <template #pickPieceWeight="{ record }">
                        <a-input v-model="record['pickPieceWeight']"></a-input>
                    </template>
                    <template #pickPieceNum="{ record }">
                        <a-input-number v-model="record.pickPieceNum"></a-input-number>
                    </template>
                </a-table>

            </div>
        </div>
    </a-drawer>
    <a-drawer ok-text='关闭' cancel-text='关闭' :footer="false" :drawer-style="{ 'zIndex': 9999 }" :hide-cancel="true"
        @cancel="visible1.showAdd = false" :width="'100%'" :height="'100%'" :visible="visible1.showAdd"
        placement="bottom">
        <template #title>
            打印布飞
        </template>
        <boufeiListdy v-model:visible1="visible1"></boufeiListdy>
    </a-drawer>
</template>

<script lang='ts' setup>
import { reactive, toRefs, ref, onMounted } from 'vue'
import { useTable, useRowKey, useTableColumn, usePagination, useRowSelection } from '@/hooks/table'
import Toolbar from '@/components/Toolbar.vue'
import { post, get } from '@/api/http'
import { Message } from '@arco-design/web-vue'
import { Modal } from '@arco-design/web-vue'
import printJS from 'print-js'
import boufeiListdy from './boufeiListdy.vue'
import { tableColumns as tableColumns1 } from '../useTableList'
import emitter from '@/hooks/useEventBus'


const table = useTable()

const tables = useTable()
const total = ref(10);
const page = ref(1);
const size = ref(10);
function PageSize(val: any) {
    page.value = val
    doRefresh();
}
function change1(val: any) {
    size.value = val
    doRefresh();
}

function doRefresh() {
    post({
        url: "planSingle/planSchedul/getPage",
        data: {
            page: page.value,
            size: size.value,
            schedulState: 2
        },
    })
        .then(({ data, code }: any) => {
            if (code === 200) {
                table.handleSuccess(data.list);
                total.value = data.total;
            }
        })
        .catch(console.log);
}

// const qx = () => {
//     visible1.showAdd = false
// }

const cx = () => {
    doRefresh()
}

// let gsDatas = ref<any[]>([])
onMounted(() => {
    pageData.rHeight = document.getElementsByClassName("main-section")[0]?.clientHeight
    //弹出层的高
    if (pageData.rHeight !== undefined) {
        pageData.rHeight = pageData.rHeight;
    }
    // doRefresh()
    // get({
    //     url:'hr/company/getAllActiveCompany'
    // }).then(res => {
    //     if (res.code == 200) {
    //         gsDatas.value = JSON.parse(res.data)
    //     }
    // })
})
const pageData = reactive({
    showAdd: false,
    rHeight: 0
})
const visible = ref(false);
const visibles1 = ref(false);
const paper =async () => {
    if (selectedRowKeys.value.length === 0) {
        Message.error('请先勾选')
        return
    }
    if (selectedRowKeys.value.length > 1) {
        Message.error('只能勾选一条')
        return
    }
    const dataListArray = table.dataList.filter((val: any) => {
        return val.id == selectedRowKeys.value[0]
    })
    const res: any = await post(
        {
            url: 'planSingle/planSchedul/getPrintMachineInfo',
            data: [
                {
                    "id": dataListArray[0].id,
                    "planOrderId": dataListArray[0].planOrderId,
                    "greyCode": dataListArray[0].greyCode,
                    "greyName": dataListArray[0].greyName
                }
            ]
        }
    )
    if (res.code == 200) {
        isDatasShuju = res.data[0]
        visible.value = true
    }
    console.log(table.dataList)
}
const handleOk = () => {

}
const { selectedRowKeys } = useRowSelection()

const tableColumns = useTableColumn([
    {
        title: "排产号",
        key: "schedulCode",
        dataIndex: "schedulCode",
        width: 150,
    },
    {
        title: "计划单号",
        key: "planOrderCode",
        dataIndex: "planOrderCode",
        width: 150,
    },
    {
        title: "计划类型",
        key: "planType",
        dataIndex: "planType",
        width: 150,
    },
    {
        title: "客户",
        key: "customName",
        dataIndex: "customName",
        width: 150,
    },
    {
        title: "机台号",
        key: "schedulMachineCode",
        dataIndex: "schedulMachineCode",
        width: 150,
    },
    {
        title: "坯布编号",
        key: "greyCode",
        dataIndex: "greyCode",
        width: 200,
    },
    {
        title: "坯布名称",
        key: "greyName",
        dataIndex: "greyName",
        width: 450,
    },
    {
        title: "产品类别",
        key: "productType",
        dataIndex: "productType",
        width: 150,
    },
    {
        title: "面料种类",
        key: "fabricType",
        dataIndex: "fabricType",
        width: 150,
    },
    {
        title: "品牌",
        key: "brandName",
        dataIndex: "brandName",
        width: 150,
        align: 'left'
    },
    {
        title: "下单重量",
        key: "orderWeight",
        dataIndex: "orderWeight",
        width: 150,
    },
    {
        title: "加工单价",
        key: "machinPrice",
        dataIndex: "machinPrice",
        width: 150,
    },
    {
        title: "加工金额",
        key: "machinMoney",
        dataIndex: "machinMoney",
        width: 150,
    },
    {
        title: "计划单状态",
        key: "planOrderState",
        dataIndex: "planOrderState",
        slotName: 'planOrderState',
        width: 150,
        fixed: 'right'
    },
    {
        title: "订单交期",
        key: "orderDeliveryDate",
        dataIndex: "orderDeliveryDate",
        width: 150,
    },
    {
        title: "计划状态",
        key: "planState",
        dataIndex: "planState",
        slotName: 'planState',
        width: 150,
    },
])


const pagination = usePagination(doRefresh)
const rowKey = useRowKey("id")

//反审
const counters = () => {
    if (selectedRowKeys.value.length === 0) {
        Message.error('请先勾选')
        return
    }
    Modal.confirm({
        title: '系统提示',
        content: '订单审核未通过',
        onOk() {
            post({
                url: 'planSingle/planSchedul/audit',
                data: [
                    {
                        id: Number(selectedRowKeys.value),
                        schedulState: 0
                    }
                ]
            }).then(({ code, data, message }: any) => {
                if (code === 200) {
                    doRefresh()
                    selectedRowKeys.value = []
                    Message.success({
                        content: '反审成功',
                        duration: 5000
                    })
                } else {
                    Message.success({
                        content: message,
                        duration: 5000
                    })
                }
            })
        }
    })
}
const exports = () => {
    if (selectedRowKeys.value.length === 0) {
        Message.error('请先勾选')
        return
    }
    Modal.confirm({
        title: '系统提示',
        content: '是否导出选择列表',
        onOk() {
            let table = document.getElementsByTagName("table")[0]
            tableToXlsx(table, '计划单已排产')
            console.log(table)
        }
    });
}

function tableToXlsx(table: any, filename: any) {
    const uri = 'data:application/vnd.ms-excel;base64,',
        template = `<html>
            <head><meta charset="UTF-8"></head>
            <body><table border="1">${table.innerHTML}</table></body>
        </html>`;

    const a = document.createElement('a');
    a.href = uri + window.btoa(unescape(encodeURIComponent(template)));
    a.download = filename;
    a.click();
    document.removeChild(a);
}
let dataForms: any = reactive({

})

const pickings = async () => {
    if (selectedRowKeys.value.length === 0) {
        Message.error('请先勾选')
        return
    }
    if (selectedRowKeys.value.length > 1) {
        Message.error('只能勾选一条')
        return
    }
    const piCodeArray = table.dataList.filter((val: any) => {
        return (selectedRowKeys.value == val.id)
    })
    //领料单
    const resu: any = await post({
        url: 'planSingle/PlanPick/getList',
        data: {
            planOrderCode: piCodeArray[0].planOrderCode
        }
    })
    if (resu.code == 200) {
        if (resu.data.length != 0) {
            Message.error('该订单已开需求单')
            return
        } else {
            //自动生成接口
            const res = await post(
                {
                    url: 'planSingle/PlanPick/getAutomaticInfo'
                }
            )
            if (res.code == 200) {
                dataForms.pickCode = res.data.pickCode
                dataForms.pickDate = res.data.pickDate
                let newDataList: any = table.dataList.filter((val: any) => {
                    return selectedRowKeys.value[0] == val.id
                })
                const resq:any = await post({
                    url: 'planSingle/PlanPick/getEditData',
                    data: newDataList[0]
                })
                if (resq.code == 200) {
                    dataForms.weaveCode = resq.data.planPick.weaveCode
                    dataForms.planOrderCode = resq.data.planPick.planOrderCode
                    dataForms.greyName = resq.data.planPick.greyName
                    dataForms.customName = resq.data.planPick.customName
                    dataForms.greyCode = resq.data.planPick.greyCode
                    tables.handleSuccess(resq.data.planPickDetail)
                    console.log(tables.dataList)
                    pageData.showAdd = true
                }else{
                    Message.error(resq.message)
                }
            }
        }
    }
}
const formRef = ref();
const sideOks = async () => {
    const DatasArry: any = table.dataList.filter((val: any) => {
        return (selectedRowKeys.value[0] == val.id)
    })
    const res = await post({
        url: 'planSingle/PlanPick/insert',
        data: [dataForms]
    })
    if (res.code == 200) {
        tables.dataList.forEach((item: any) => {
            item.planPickId = res.data
            item.planOrderId = DatasArry[0].planOrderId
        })
        const resz = await post({
            url: 'planSingle/PlanPickDetail/insert',
            data: tables.dataList
        })
        if (resz.code == 200) {
            Message.success('保存成功')
            formRef.value?.resetFields()
            tables.handleSuccess([])
            pageData.showAdd = false
        }
    }
}

const sideNo1 = () => {
    pageData.showAdd = false
}
const print = () => {
    printJS({
        printable: 'jtdy2',
        type: 'html',
        targetStyles: ['*'],
    })
}
const prints = () => {
    printJS({
        printable: 'zbdy2',
        type: 'html',
        targetStyles: ['*'],
    })
}
const visible1 = reactive({
    showAdd: false
})
const dyBf = async () => {
    if (selectedRowKeys.value.length === 0) {
        Message.error('请先勾选')
        return
    }
    if (selectedRowKeys.value.length > 1) {
        Message.error('只能勾选一条')
        return
    }
    const jvData: any = table.dataList.filter((res: any) => {
        return selectedRowKeys.value[0] == res.id
    })
    if (jvData[0].customName == '') {
        Message.error('该计划单没有选择客户名称')
        return
    } else {
        emitter.emit('hqJhd', jvData)
        const res:any = await post({
            url: 'planSingle/clothfiy/getAutomaticInfo',
            data: {
                customName: jvData[0].customName
            }
        })
        if (res.code == 200) {
            emitter.emit('hqzdy', res.data)
            visible1.showAdd = true
        }else{
            Message.error(res.message)
        }
    }
}

const zzpzdata = ref<any>()
const sjdata: any = reactive<{ sj: any[] }>({ sj: [] })
let psList = ref<any[]>([])
const ckpzobj = reactive({
    id: 0,
    pinHeader: '',
    arrangement: ''
})
const tags = [{ id: '1', val: '̶' }, { id: '2', val: "Ո" }, { id: '3', val: 'Ս' }, { id: '4', val: 'Ʌ' }, {
    id: '5',
    val: 'V'
}]

let isDatasShuju:any = reactive({
    grey:[{}],
    planOrderRawmaterials:[{}],
    machineStandard:[{}]
}) 
const zbtzds = async () => {
    if (selectedRowKeys.value.length === 0) {
        Message.error('请先勾选')
        return
    }
    if (selectedRowKeys.value.length > 1) {
        Message.error('只能勾选一条')
        return
    }
    const dataListArray = table.dataList.filter((val: any) => {
        return val.id == selectedRowKeys.value[0]
    })
    const res: any = await post(
        {
            url: 'planSingle/planSchedul/getPrintMachineInfo',
            data: [
                {
                    "id": dataListArray[0].id,
                    "planOrderId": dataListArray[0].planOrderId,
                    "greyCode": dataListArray[0].greyCode,
                    "greyName": dataListArray[0].greyName
                }
            ]
        }
    )
    if (res.code == 200) {
        if(res.data[0].grey.length != 0){
            isDatasShuju = res.data[0]
        post({
            url: 'product/pdGreyInformation/select',
            data: {
                id: res.data[0].grey[0].id
            }
        }).then(({ code, data }) => {
            if (code === 200) {
                // 组织排针 数据
                zzpzdata.value = data.organizationPinSons.length == 0 ? [{
                    "upBasin": "",
                    belowBasin: "",
                    id: "",
                    pdOrganizationPinId: ''
                }] : data.organizationPinSons;
                // 裁口排针
                if (data.cuttingMouthNeedleGrey != null) {
                    let cuttingMouthNeedleGrey = data.cuttingMouthNeedleGrey
                    ckpzobj.id = cuttingMouthNeedleGrey.id;
                    ckpzobj.pinHeader = cuttingMouthNeedleGrey.pinHeader;
                    ckpzobj.arrangement = cuttingMouthNeedleGrey.arrangement;
                }
                // 排三角arrangementTriangleGreys
                sjdata.sj = data.arrangementTriangleGreys.info
                // sjdata.sjid=data.arrangementTriangleGreys.greyId
                // psjpb.value=data.arrangementTriangleGreys.greyId 现有坯布
                sjdata.atCode = data.arrangementTriangleGreys.atCode
                sjdata.atName = data.arrangementTriangleGreys.atName
                sjdata.remark = data.arrangementTriangleGreys.remark
                psList.value = data.atOther
            } else {
                Message.error('获取原料失败')
            }
        })
        visibles1.value = true
        }else{
            Message.error('计划单坯布不存在')
        }
    }else{
        Message.error('未知错误')
    }

}
</script>
<style lang='less' scoped>
.cssToolbar {
    text-align: right;
    margin-bottom: 2px;
}

.isZbous {
    width: 750px;
    margin-left: 15px;
    margin: 0;
    padding: 0;
    margin: 0 auto;
    .isZbouss {
        width: 80%;
        margin-left: 30%;
        font-size: 18px;
        font-weight: 600;
    }

    .isZbouss1 {
        width: 100%;
        margin: 0 auto;
        display: flex;
        justify-content: space-between;
        font-size: 16px;
        font-weight: 600;
    }

    .isZbouss2 {
        width: 100%;
        margin: 0 auto;
        display: flex;
        justify-content: space-between;
        font-size: 16px;
        font-weight: 600;
    }
}

.isTable {
    width: 100%;
    height: 100px;
    margin: 0 auto;
    border: 1.2px solid #ccc;
    text-align: center;
    border-collapse: collapse;
    tr{
        height: 10px;
    }
    td {
        border: 1.2px solid #ccc;
    }
}

.isTable1 {
    width: 100%;
    height: 100px;
    margin: 0 auto;
    border: 1.2px solid #ccc;
    text-align: center;
    border-collapse: collapse;
    margin-top: 20px;

    td {
        border: 1.2px solid #ccc;
    }

    .isTrTdNo {
        td {
            border-top: 1.2px solid #fff;
            border-right: 1.2px solid #fff;
            border-left: 1.2px solid #fff;
            color: #fff;
            opacity: 0;
        }
    }
}

.footer {
    width: 100%;
    margin: 0 auto;
    margin-top: 20px;
    text-align: left;
}

.gyYaoqiu {
    width: 100%;
    text-align: center;
    font-size: 16px;
    margin: 0 auto;
    border-bottom: 1.2px solid #ccc;
    border-left: 1.2px solid #ccc;
    border-right: 1.2px solid #ccc;
}


.thead {
    white-space: nowrap;
    justify-content: center;

    .th {
        box-sizing: border-box;
        text-align: center;
        display: inline-block;
    }

    width: 100%;
    text-align: left;
}

.tbody {
    white-space: nowrap;
    justify-content: center;

    .td {
        text-align: center;
        box-sizing: border-box;
        display: inline-block;
    }

    text-align: left;
}

.trow>div {
    display: inline-block;
    text-align: center;
}

.active {
    width: 80px !important;

}
.gyYaoqius{
    width: 100%;
    margin: 0 auto;
    border-bottom: 1.2px solid #ccc;
    border-left: 1.2px solid #ccc;
    border-right: 1.2px solid #ccc;
}
.trTds{
    font-size: 16px;
    font-weight: 600;
}
.footers{
    width: 100%;
    margin: 0 auto;
    div{
        display: flex;
        justify-content: space-between;
        font-size: 16px;
        
    }
}
</style>